<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
<h1>简易计算器</h1>
<p><input type="text" id='num1'></p>
<p><input type="text" id='num2'></p>
<input type="button" value="+" id='opa' onclick="getResult('+')">
<input type="button" value="-" id='opa' onclick="getResult('-')">
<input type="button" value="*" id='opa' onclick="getResult('*')">
<input type="button" value="/" id='opa' onclick="getResult('/')">
<p>计算结果:<span id='result'>0</span></p>
</body>
<script>
	function getResult(opa){
		var num1=Number(document.getElementById('num1').value);
		var num2=Number(document.getElementById('num2').value);
			switch(opa){
				case '+':
				result.innerText=num1+num2;
				break;
				case '-':
				result.innerText=num1-num2;
				break;
				case '*':
				result.innerText=num1*num2;
				break;
				case '/':
				result.innerText=num1/num2;
				break;
				}
		}
	</script>
</html>